#@head("设置角色")
#define main()
#end
<body>
	<div class="layui-form" lay-filter="layuiadmin-form-system" id="layuiadmin-form-system" style="margin:auto; padding: 20px;">
		<div class="layui-form-item">
			<div id="user-role-transfer"></div>
	    </div>
		<input type="hidden" id="rIds" name="rIds" />
		<div class="layui-form-item layui-hide">
			<input type="button" lay-submit lay-filter="LAY-user-role-front-submit" id="LAY-user-role-front-submit" value="确认">
		</div>
	</div>
	#@layui()
	#define use()
		use(["index", "form", "transfer"], function(){
			var $ = layui.$,
			form = layui.form,
			transfer  = layui.transfer;
			
			transfer.render({
				elem: "#user-role-transfer",
				title: ["待选择角色", "已选择角色"],
				data: #(list??),
				value: [#(roleids??)],
				id: "user-role",
				text: {
					none: "暂未设置角色"
				},
				onchange: function(data, index){
					var getData = transfer.getData("user-role"); //获取右侧数据
					var ids = new Array();
					if(getData.length>0){
						for(var i=0; i < getData.length; i++){
							ids.push(getData[i].value);
						}
					}
					$("#rIds").val(ids.join(","));
				}
			})
		})
	#end
</body>
</html>